package com.bins.dentist.clinic.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bins.dentist.clinic.model.dto.UserDto;
import com.bins.dentist.clinic.model.dto.UserPageDto;
import com.bins.dentist.clinic.model.vo.ResultVo;
import com.bins.dentist.clinic.model.vo.UserPageVo;
import com.bins.dentist.clinic.model.vo.UserVo;
import com.bins.dentist.clinic.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author bins
 * @since 2023-02-20 20:53:31
 */
@RestController
@RequestMapping("/system/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/page")
    public ResultVo<IPage<UserPageVo>> pageList(UserPageDto pageDto) {
        return ResultVo.ok().data(userService.getPage(pageDto));
    }

    @PostMapping("/save")
    public ResultVo<UserVo> save(@RequestBody UserDto dto) {
        return ResultVo.ok().data(userService.saveUser(dto));
    }

    @GetMapping("/detail")
    public ResultVo<UserVo> detail(UserDto dto) {
        return ResultVo.ok().data(userService.userDetail(dto));
    }

    @PostMapping("/delete")
    public ResultVo<UserVo> deleteUser(@RequestBody UserDto dto) {
        return ResultVo.ok().data(userService.deleteUser(dto));
    }

    @PostMapping("/refreshCache")
    public ResultVo<UserVo> refreshCache(@RequestBody UserDto dto) {
        return ResultVo.ok().data(userService.refreshCache(dto));
    }

    @PostMapping("/offlineUser")
    public ResultVo<UserVo> offlineUser(@RequestBody UserDto dto) {
        return ResultVo.ok().data(userService.offlineUser(dto));
    }

    @PostMapping("/resetPassword")
    public ResultVo<UserVo> resetPassword(@RequestBody UserDto dto) {
        return ResultVo.ok().data(userService.resetPassword(dto));
    }

    @PostMapping("/updateLockStatus")
    public ResultVo<UserVo> updateLockStatus(@RequestBody UserDto dto) {
        return ResultVo.ok().data(userService.updateLockStatus(dto));
    }

}

